import com.xinzi.calculation.interpolation_methods as interpolation
import com.xinzi.calculation.dichotomy as dichotomy


def my_interpolation():
    target_list = [10, 12, 14, 16]
    for target in target_list:
        res1, error1 = interpolation.lagrange(target)
        # print("第", target, "日拉格朗日插值法预测结果为:", res1, "绝对误差为:", error1)

        res2, error2 = interpolation.newton(target)
        print("第", target, "日牛顿插值法预测结果为:", res2, "绝对误差为:", error2)


def my_dichotomy():
    error = 0.005
    e = 2.718282
    res = dichotomy.do_calculate(0, 1, error, lambda x: e ** x + 10 * x - 2)
    print(res)


if __name__ == '__main__':
    my_interpolation()
    # my_dichotomy()
